package ae.pcfc.etks.online.itworx.ehs.web.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.hibernate.annotations.ForeignKey;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;

@Entity
@Table(name = "T_EHS_OFC_REQUEST")
@PrimaryKeyJoinColumn(name = "EHS_OFC_REQUEST_ID")
@XmlRootElement(name = "ofcRequest")
@XmlAccessorType(XmlAccessType.FIELD)
public class OFCRequest extends Request implements Serializable {

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@ForeignKey(name = "FK_OFC_REQUEST_REQ_DOC", inverseName = "FK_REQ_DOC_OFC_REQUEST")
	@JoinTable(
        name="T_EHS_OFC_REQ_DOC",
        joinColumns=@JoinColumn(name="EHS_OFC_REQUEST_ID", referencedColumnName="EHS_OFC_REQUEST_ID"),
        inverseJoinColumns=@JoinColumn(name="EHS_OFC_DOCUMET_ID", referencedColumnName="EHS_OFC_DOCUMET_ID"))
	private List<OFCDocument> documents=new ArrayList<OFCDocument>();
	@Column(name = "OFFICER_COMMENTS", length = 500)
	private String officerComments;
	@Column(name = "BUSINESS_UNIT", length = 50)
	@XmlElement
	private String businessUnit;
	@Column(name = "TRADE_LICENSE_NUMBER", length = 50)
	@XmlElement
	private String licenseNumber;
	@Column(name = "ENG_ACTIVITY", length = 4000)
	@XmlElement
	private String engActivity;
	@Column(name = "AR_ACTIVITY", length = 4000)
	@XmlElement
	private String arActivity;
	@Column(name = "LOCATION", nullable = false, length = 50)
	@XmlElement
	private String location;
	@Column(name = "BCC", length = 30)
	@Length(max=30)
	@XmlElement
	private String bcc;
	@Column(name = "MAIN_EMAIL", length = 50)
	@Length(max=50)
	@Email
	@XmlElement
	private String mainEmail;
	@Column(name = "OPTIONAL_EMAIL", length = 50)
	@Length(max=50)
	@Email
	@XmlElement
	private String optionalMail;
	@Column(name = "REQUESTED_BY", length = 50)
	@Length(max=50)
	@XmlElement
	private String requestedBy;
	@Column(name = "REMARK", length = 500)
	@Length(max=500)
	@XmlElement
	private String remarks;
	@Column(name = "CONTACT_PERSON_NAME", nullable = false, length = 50)
	@Length(max=50)
	@XmlElement
	private String contactPersonName;
	@Column(name = "TELEPHONE", nullable = false, length = 30)
	@Length(max=30)
	@XmlElement
	private String telephone;
	@Column(name = "FAX", length = 30)
	@Length(max=30)
	@XmlElement
	private String fax;
	@Column(name = "MOBILE", length = 30)
	@Length(max=30)
	@XmlElement
	private String mobile;
	@Column(name = "ALT_EMAIL", nullable = false, length = 50)
	@Length(max=50)
	@Email
	@XmlElement
	private String alternativeEmail;
	@Column(name = "AMENDMENT_TYPE", length = 150)
	private String amendmentType;
	
	public String getArActivity() {
		return arActivity;
	}

	public void setArActivity(String arActivity) {
		this.arActivity = arActivity;
	}
	
	public String getAmendmentType() {
		return amendmentType;
	}

	public void setAmendmentType(String amendmentType) {
		this.amendmentType = amendmentType;
	}

	public String getOptionalMail() {
		return optionalMail;
	}

	public void setOptionalMail(String optionalMail) {
		this.optionalMail = optionalMail;
	}

	@Column(name = "IMS_Log_ID", length = 10)
	private String imsLogId;
	@Column(name = "IMS_STATUS", length = 50)
	private String imsStatus;
	@OneToMany(cascade = {CascadeType.ALL} , fetch = FetchType.LAZY)
	@ForeignKey(name = "FK_OFC_REQUEST_REQ_HIS", inverseName = "FK_REQ_HIS_OFC_REQUEST")
	@JoinTable(
        name="T_EHS_OFC_REQ_HIS",
        joinColumns=@JoinColumn(name="EHS_OFC_REQUEST_ID", referencedColumnName="EHS_OFC_REQUEST_ID"),
        inverseJoinColumns=@JoinColumn(name="EHS_OFC_REQUEST_HISTORY_ID", referencedColumnName="EHS_OFC_REQUEST_HISTORY_ID"))
    @OrderBy("processingDate asc")
	private List<OFCRequestHistory> ofcHistory=new ArrayList<OFCRequestHistory>();
	@OneToMany(cascade = CascadeType.ALL)
	@ForeignKey(name = "FK_OFC_REQUEST_REQ_FNP", inverseName = "FK_REQ_FNP_OFC_REQUEST")
	@JoinTable(
        name="T_EHS_OFC_REQ_FNP",
        joinColumns=@JoinColumn(name="EHS_OFC_REQUEST_ID", referencedColumnName="EHS_OFC_REQUEST_ID"),
        inverseJoinColumns=@JoinColumn(name="EHS_FNP_DETAIL_ID", referencedColumnName="EHS_FNP_DETAIL_ID"))
    @OrderBy("id asc")
	private List<FNPDetails> fnpList=new ArrayList<FNPDetails>();
	@Column(name = "REJECTION_REASON")
	private String rejectionReason;
	@OneToMany(cascade = CascadeType.ALL)
	@ForeignKey(name = "FK_OFC_REQUEST_REQ_COMM", inverseName = "FK_REQ_COMM_OFC_REQUEST")
	@JoinTable(
        name="T_EHS_OFC_REQ_COMMENT",
        joinColumns=@JoinColumn(name="EHS_OFC_REQUEST_ID", referencedColumnName="EHS_OFC_REQUEST_ID"),
        inverseJoinColumns=@JoinColumn(name="EHS_COMMENT_ID", referencedColumnName="EHS_COMMENT_ID"))
	@OrderBy("imsDeptId ,imsCommentSeqNo asc")
    private List<Comment> comments= new ArrayList<Comment>();
	@Column(name = "PAYMENT_CONTACT_PERSON")
	private String paymentContactPerson;
	
	public String getPaymentContactPerson() {
		return paymentContactPerson;
	}

	public void setPaymentContactPerson(String paymentContactPerson) {
		this.paymentContactPerson = paymentContactPerson;
	}

	public List<Comment> getComments() {
		return comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	public String getRejectionReason() {
		return rejectionReason;
	}

	public void setRejectionReason(String rejectionReason) {
		this.rejectionReason = rejectionReason;
	}

	public List<FNPDetails> getFnpList() {
		return fnpList;
	}

	public void setFnpList(List<FNPDetails> fnpList) {
		this.fnpList = fnpList;
	}

	public List<OFCDocument> getDocuments() {
		return documents;
	}

	public void setDocuments(List<OFCDocument> documents) {
		this.documents = documents;
	}

	public String getOfficerComments() {
		return officerComments;
	}

	public void setOfficerComments(String officerComments) {
		this.officerComments = officerComments;
	}

	public String getBusinessUnit() {
		return businessUnit;
	}

	public void setBusinessUnit(String businessUnit) {
		this.businessUnit = businessUnit;
	}

	public String getLicenseNumber() {
		return licenseNumber;
	}

	public void setLicenseNumber(String licenseNumber) {
		this.licenseNumber = licenseNumber;
	}

	public String getEngActivity() {
		return engActivity;
	}

	public void setEngActivity(String engActivity) {
		this.engActivity = engActivity;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getBcc() {
		return bcc;
	}

	public void setBcc(String bcc) {
		this.bcc = bcc;
	}

	public String getMainEmail() {
		return mainEmail;
	}

	public void setMainEmail(String mainEmail) {
		this.mainEmail = mainEmail;
	}

	public String getRequestedBy() {
		return requestedBy;
	}

	public void setRequestedBy(String requestedBy) {
		this.requestedBy = requestedBy;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getContactPersonName() {
		return contactPersonName;
	}

	public void setContactPersonName(String contactPersonName) {
		this.contactPersonName = contactPersonName;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getAlternativeEmail() {
		return alternativeEmail;
	}

	public void setAlternativeEmail(String alternativeEmail) {
		this.alternativeEmail = alternativeEmail;
	}

	public String getImsLogId() {
		return imsLogId;
	}

	public void setImsLogId(String imsLogId) {
		this.imsLogId = imsLogId;
	}

	public String getImsStatus() {
		return imsStatus;
	}

	public void setImsStatus(String imsStatus) {
		this.imsStatus = imsStatus;
	}

	public List<OFCRequestHistory> getOfcHistory() {
		return ofcHistory;
	}

	public void setOfcHistory(List<OFCRequestHistory> ofcHistory) {
		this.ofcHistory = ofcHistory;
	}
}
